package com.example.mydemo.controller.hc;


import com.example.config.DailyExpenseEsRepository;


import com.example.entity.DailyExpense;
import com.example.mydemo.model.ClockVO;
import com.example.mydemo.model.tableVO;
import com.example.mydemo.service.DailyExpenseService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;

@Controller
@RequestMapping()
public class DailyExpenseController {


    private DailyExpenseEsRepository expenseService;
    @GetMapping("/getDailyExpense")
    @ResponseBody
    public tableVO selectDeptCount(@RequestParam Long page, @RequestParam Long limit) {
//        Pageable usepage = Pageable.ofSize(Math.toIntExact(limit)); // 创建分页对象，当前页为1，每页显示5条记录
        Page<DailyExpense> entityPage = expenseService.findAll(PageRequest.of(0, 10));
        tableVO a = new tableVO();
        a.setCode(0L);
        a.setMsg("");
        a.setData(entityPage.getContent());
        a.setCount((long) entityPage.getTotalPages());
        return a;
    }

}
